R Presentation
reveal-js

February 24th, 2021

R Markdown

This is an R Markdown presentation. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document.

Example of slides

Slide with Bullets

  • This is the first to be shown [1, 2].

  • This is the second to be shown

  • This is not incremental
  • Neither this one

Slide with Bullets

  • fade-out 1
  • fade-out 3
  • fade-out 2

Slide with R Code and Output

summary(cars)
##      speed           dist       
##  Min.   : 4.0   Min.   :  2.00  
##  1st Qu.:12.0   1st Qu.: 26.00  
##  Median :15.0   Median : 36.00  
##  Mean   :15.4   Mean   : 42.98  
##  3rd Qu.:19.0   3rd Qu.: 56.00  
##  Max.   :25.0   Max.   :120.00

Slide with Plot

Here the code that produces the plot is hidden

Transitions

Test of different type of transitions

grow

shrink

fade-out

fade-up (also down, left and right!)

fade-right, up, down, left

fades in, then out when we move to the next step

again fade-in

Slides with dynamic plots

Plotly graph

r2d3 graph

svg.selectAll('rect')
  .data(data)
  .enter()
    .append('rect')
      .attr('width', d => d * 10)
      .attr('height', '20px')
      .attr('y', (d, i) => i * 22)
      .attr('fill', options.color);

r2d3 graph with external file

library(r2d3)
r2d3(data=c(0.3, 0.6, 0.8, 0.95, 0.40, 0.20), script = "d3-barchart.js")

Inserting our pie-chart

Few more things

Embedding javascript

<div id="testjs">Hello</div>
Hello
function change_color(){
  var div=document.getElementById('testjs')
  div.style.color='green';
  div.style.fontSize = "150%";
  div.innerHTML = "Hello " + my_data;
}
<button onclick="change_color">Change color</button>

Embedding CSS

Some embedded CSS code

#testcss {
  color: red;
}
<div id="testcss">Hello</div>
Hello

Equations

getting started

We can write fractions: \(\frac{2}{3}\). We can also handle things like estimated population growth rate, e.g., \(\hat{\lambda}=1.02\). And, \(\sqrt{4}=2\).

\[\alpha, \beta, \gamma, \Gamma\]

\[a \pm b\] \[x \ge 15\] \[a_i \ge 0~~~\forall i\]

Matrix

\[A_{m,n} = \begin{pmatrix} a_{1,1} & a_{1,2} & \cdots & a_{1,n} \\ a_{2,1} & a_{2,2} & \cdots & a_{2,n} \\ \vdots & \vdots & \ddots & \vdots \\ a_{m,1} & a_{m,2} & \cdots & a_{m,n} \end{pmatrix}\]

Referencing equations

\begin{equation}
  \int_0^\infty \frac{x^3}{e^x-1}\,dx = \frac{\pi^4}{15}
  \label{eq:sample}\tag{1}
\end{equation} 

\[\begin{equation} \int_0^\infty \frac{x^3}{e^x-1}\,dx = \frac{\pi^4}{15} \label{eq:sample}\tag{1} \end{equation}\]

Refer to it using $\eqref{eq:sample}$, e.g., see \(\eqref{eq:sample}\)

References

[1]
Wickham, H. and Grolemund, G. (2017). R for data science: Import, tidy, transform, visualize, and model data. O’Reilly Media, Inc.
[2]
Wickham, H. (2016). ggplot2: Elegant graphics for data analysis. Springer-Verlag New York.